// 189. 旋转数组

/**
 * @param {number[]} nums
 * @param {number} k
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var rotate = function (nums, k) {
    const reverse = (arr, l, r) => {
        while (l < r) {
            [arr[l++], arr[r--]] = [arr[r], arr[l]];
        }
    };
    while (k > nums.length) k -= nums.length;
    reverse(nums, 0, nums.length - 1);
    reverse(nums, 0, k - 1);
    reverse(nums, k, nums.length - 1);
};
